FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 5208
EXPOSE 5209

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY src/api/dreamwork.exam.api/dreamwork.exam.api.csproj src/api/dreamwork.exam.api/
COPY src/buildingblocks/infrastucture/dreamwork.core/dreamwork.core.csproj src/buildingblocks/infrastucture/dreamwork.core/
RUN dotnet restore src/api/dreamwork.exam.api/dreamwork.exam.api.csproj
COPY . .
WORKDIR /src/src/api/dreamwork.exam.api
RUN dotnet build dreamwork.exam.api.csproj -c Release -o /app

FROM build AS publish
RUN dotnet publish dreamwork.exam.api.csproj -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "dreamwork.exam.api.dll"]
